<?php
namespace app\models\config;
use app\models\BaseForm;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SiteForm
 *
 * @author shuai
 */
class SiteForm extends BaseForm {
    
    
    
     public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    protected $houzhui = 'site';

 
 public function save() {
       
        
        $transaction = \Yii::$app->db->beginTransaction();
        try { 
            $model = new \app\models\Config;
            $model->BaseForm = $this;
            foreach ($this->attributeLabels() as $key => $vo) {
                if($key=='weixin_appsecret'){
                    \app\models\Log::$isWrite=false;
                }else{
                    \app\models\Log::$isWrite=true;
                }
                if($key=='weixin_appsecret'&&$this->$key=='你懂得'){
                    
                }else{
                   $model->set_val($key, $this->houzhui, $this->$key); 
                } 
            }
            $transaction->commit();
             \app\components\Lcms::flush();
             return true;
        } catch (Exception $ex) { 
            Fun::showmsg($ex->getMessage());
            $transaction->rollBack(); ///回滚
        } 
        return true;
    }



    public $share_img;
        public $share_desc;
        public $share_title;
        public $share_url;
        public $quanju;  
        public $share_wx_debug;
        public $weixin_appId;
        public $weixin_appsecret;  
        
            public $verifyCode;
          /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
                          ['verifyCode', 'captcha','captchaAction'=>'/admin/site/captcha'],
            [[ 'share_img','share_desc','share_title','share_url','quanju','weixin_appsecret','weixin_appId','share_wx_debug'], 'safe'], 
             
        ];
    }
    
    public function attributeLabels()
	{
		
		return [ 
                     'share_img'=>'分享图片',
                     'share_desc'=>'分享文案',
                     'share_title'=>'分享标题',
                     'share_url'=>'分享地址',
                    'quanju'=>'全局代码',  
                         'verifyCode' => '验证码',  
                    'weixin_appId'=>'weixin_appId',
                    'weixin_appsecret'=>'weixin_appsecret',
                    'share_wx_debug'=>'微信分享调试模式',
                 
		];
	}

}
